const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const {
    srcPath
} = require('./paths');

module.exports = {
    entry: {
        index: path.join(srcPath, 'index.js'),
    },
    module: {
        rules: [
            {
                test: /\.(js|jsx)$/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        cacheDirectory: true, // 开启缓存
                        presets: ['@babel/preset-react']
                    }
                },
                include: srcPath,
                // exclude: /node_modules/
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: path.join(srcPath, 'index.html'),
            filename: 'index.html'
        })
    ],
    resolve: {
        extensions: [".js", ".jsx", ".json"]
    }
};